cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

set(CMAKE_C_COMPILER "clang")

project(rnnoise-native LANGUAGES C)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)

set(BIN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR})

if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  message(FATAL_ERROR "
    CMake generation is not allowed within the source directory!
    Remove the CMakeCache.txt file and try again from another folder, e.g.:
    mkdir build && cd build
    cmake ..
  ")
endif()

if (NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_C_FLAGS_RELEASE "-O2 -Wall -Wno-null-dereference -Wno-deprecated-declarations")

if (WIN32)
  add_definitions(-D_USE_MATH_DEFINES)
endif()

include_directories(include rnnoise/include)

file(GLOB MAIN_SRC src/main.c)
file(GLOB RNNOISE_SRC rnnoise/src/*.c)

add_executable(rnnoise-app ${MAIN_SRC} ${RNNOISE_SRC})
target_link_libraries(rnnoise-app m)
